Imports System.IO
Imports WinXound_Net.gVar


Public Class FormAnalysis


    Private Sub FormAnalysis_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        WxUtilityConsole1.ButtonFindError.Visible = False
        WxUtilityConsole1.SCI_Output.StyleSetSize(STYLE_DEFAULT, 8.25!)
        WxUtilityConsole1.SCI_Output.SetZoom(0)
        WxUtilityConsole1.SCI_Error.StyleSetSize(STYLE_DEFAULT, 8.25!)
        WxUtilityConsole1.SCI_Error.SetZoom(0)

        Me.Text = "CSound Analysis"
        Dim mFile As String = Application.StartupPath & "\Help\atsa.html"
        If File.Exists(mFile) Then
            WebBrowserHelp.Navigate(mFile)
        End If

        'Prepare data tabs
        SetDefaultValues("ATSA")
        SetDefaultValues("CVANAL")
        SetDefaultValues("HETRO")
        SetDefaultValues("LPANAL")
        SetDefaultValues("PVANAL")

        'Hide Extended compiler info window
        WxUtilityConsole1.GroupBox2.Visible = False
        WxUtilityConsole1.Splitter2.Visible = False

    End Sub


    Private Sub ButtonResetAtsa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonResetAtsa.Click
        SetDefaultValues("ATSA")
    End Sub

    Private Sub ButtonResetCvanal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonResetCvanal.Click
        SetDefaultValues("CVANAL")
    End Sub

    Private Sub ButtonResetHetro_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonResetHetro.Click
        SetDefaultValues("HETRO")
    End Sub

    Private Sub ButtonResetLpanal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonResetLpanal.Click
        SetDefaultValues("LPANAL")
    End Sub

    Private Sub ButtonResetPvanal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonResetPvanal.Click
        SetDefaultValues("PVANAL")
    End Sub

    Private Sub SetDefaultValues(ByVal mUtilityName As String)

        Select Case mUtilityName

            Case "ATSA"
                b_Atsa.Value = 0
                e_Atsa.Value = 0
                l_Atsa.Value = 20
                Max_Atsa.Value = 20000
                d_Atsa.Value = 0.1
                c_Atsa.Value = 4
                w_Atsa.SelectedIndex = 1
                F_File_Atsa.SelectedIndex = 3
                h_Atsa.Value = 0.25
                m_Atsa.Value = -60
                t_Atsa.Value = 3
                s_Atsa.Value = 3
                g_Atsa.Value = 3
                T_SMR_Atsa.Value = 30
                S_SMR_Atsa.Value = 60
                P_Peak_Atsa.Value = 0
                M_SMR_Atsa.Value = 0.5

            Case "CVANAL"
                s_Cvanal.Value = 10000
                c_Cvanal.Value = 0
                b_Cvanal.Value = 0
                d_Cvanal.Value = 0

            Case "HETRO"
                s_Hetro.Value = 10000
                c_Hetro.Value = 1
                b_Hetro.Value = 0
                d_Hetro.Value = 0
                f_Hetro.Value = 100
                Max_Hetro.Value = 32767
                n_Hetro.Value = 256
                h_Hetro.Value = 10
                min_Hetro.Value = 64
                l_Hetro.Value = 0

            Case "LPANAL"
                s_Lpanal.Value = 10000
                c_Lpanal.Value = 1
                b_Lpanal.Value = 0
                d_Lpanal.Value = 0
                p_Lpanal.Value = 34
                Min_Lpanal.Value = 70
                Max_Lpanal.Value = 200
                h_Lpanal.Value = 200
                v_Lpanal.SelectedIndex = 0
                a_Lpanal.Checked = False
                Comments_Lpanal.Text = ""

            Case "PVANAL"
                s_Pvanal.Value = 10000
                c_Pvanal.Value = 1
                b_Pvanal.Value = 0
                d_Pvanal.Value = 0
                n_Pvanal.Text = "2048"
                w_Pvanal.SelectedIndex = 0
                h_Pvanal.Text = "128"
                window_Pvanal.Text = "Von Hann"

        End Select

    End Sub



    Private Sub ButtonStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonStart.Click
        If Preferences.Directory.CSoundConsole = "" Or _
            Not File.Exists(Preferences.Directory.CSoundConsole) Then
            MessageBox.Show("Cannot find CSound compiler!" & vbCrLf & _
                            "Please select a valid path in File->Settings->CSound.exe", _
                            "Compiler error!", MessageBoxButtons.OK, MessageBoxIcon.Error)

            Exit Sub
        End If

        Select Case TabControl1.SelectedTab.Name.Substring(3)
            Case "Atsa"
                If InputFile_Atsa.Text = "" Then
                    wxMessageError("Input file not specified", "Error")
                    Exit Sub
                End If
                If OutputFile_Atsa.Text = "" Then
                    wxMessageError("Output file not specified", "Error")
                    Exit Sub
                End If
                Call ATSA()

            Case "Cvanal"
                If InputFile_Cvanal.Text = "" Then
                    wxMessageError("Input file not specified", "Error")
                    Exit Sub
                End If
                If OutputFile_Cvanal.Text = "" Then
                    wxMessageError("Output file not specified", "Error")
                    Exit Sub
                End If
                Call CVANAL()

            Case "Hetro"
                If InputFile_Hetro.Text = "" Then
                    wxMessageError("Input file not specified", "Error")
                    Exit Sub
                End If
                If OutputFile_Hetro.Text = "" Then
                    wxMessageError("Output file not specified", "Error")
                    Exit Sub
                End If
                Call HETRO()

            Case "Lpanal"
                If InputFile_Lpanal.Text = "" Then
                    wxMessageError("Input file not specified", "Error")
                    Exit Sub
                End If
                If OutputFile_Lpanal.Text = "" Then
                    wxMessageError("Output file not specified", "Error")
                    Exit Sub
                End If
                Call LPANAL()

            Case "Pvanal"
                If InputFile_Pvanal.Text = "" Then
                    wxMessageError("Input file not specified", "Error")
                    Exit Sub
                End If
                If OutputFile_Pvanal.Text = "" Then
                    wxMessageError("Output file not specified", "Error")
                    Exit Sub
                End If
                Call PVANAL()

            Case "Sndinfo"
                If InputFile_Sndinfo.Text = "" Then
                    wxMessageError("Input file not specified", "Error")
                    Exit Sub
                End If
                Call SNDINFO()

        End Select

    End Sub


    Private Sub ATSA()
        Dim tArguments As String = " -U atsa "
        Dim tFlags As String = ""

        If b_Atsa.Value > 0 Then
            tFlags &= "-b" & b_Atsa.Value & " "
        End If
        If e_Atsa.Value > 0 Then
            tFlags &= "-e" & e_Atsa.Value & " "
        End If
        If l_Atsa.Value <> 20 Then
            tFlags &= "-l" & l_Atsa.Value & " "
        End If
        If Max_Atsa.Value <> 20000 Then
            tFlags &= "-H" & Max_Atsa.Value & " "
        End If
        If d_Atsa.Value <> 0.1 Then
            tFlags &= "-d" & d_Atsa.Value & " "
        End If
        If c_Atsa.Value <> 4 Then
            tFlags &= "-c" & c_Atsa.Value & " "
        End If
        If w_Atsa.SelectedIndex <> 1 Then
            tFlags &= "-w" & w_Atsa.SelectedIndex & " "
        End If
        If h_Atsa.Value <> 0.25 Then
            tFlags &= "-h" & h_Atsa.Value & " "
        End If
        If m_Atsa.Value <> -60 Then
            tFlags &= "-m" & m_Atsa.Value & " "
        End If
        If t_Atsa.Value <> 3 Then
            tFlags &= "-t" & t_Atsa.Value & " "
        End If
        If s_Atsa.Value <> 3 Then
            tFlags &= "-s" & s_Atsa.Value & " "
        End If
        If g_Atsa.Value <> 3 Then
            tFlags &= "-g" & g_Atsa.Value & " "
        End If
        If T_SMR_Atsa.Value <> 30 Then
            tFlags &= "-T" & T_SMR_Atsa.Value & " "
        End If
        If S_SMR_Atsa.Value <> 60 Then
            tFlags &= "-S" & S_SMR_Atsa.Value & " "
        End If
        If P_Peak_Atsa.Value > 0 Then
            tFlags &= "-P" & P_Peak_Atsa.Value & " "
        End If
        If M_SMR_Atsa.Value <> 0.5 Then
            tFlags &= "-M" & M_SMR_Atsa.Value & " "
        End If
        If F_File_Atsa.SelectedIndex <> 3 Then
            tFlags &= "-F" & F_File_Atsa.SelectedIndex + 1 & " "
        End If

        tArguments &= tFlags & _
                      """" & InputFile_Atsa.Text.Trim & """" & _
                      " " & _
                      """" & OutputFile_Atsa.Text.Trim & """"

        StartCompiler(tArguments)
    End Sub

    Private Sub CVANAL()
        Dim tArguments As String = " -U cvanal "
        Dim tFlags As String = ""

        If s_Cvanal.Value <> 10000 Then
            tFlags &= "-s" & s_Cvanal.Value & " "
        End If
        If c_Cvanal.Value > 0 Then
            tFlags &= "-c" & c_Cvanal.Value & " "
        End If
        If b_Cvanal.Value > 0 Then
            tFlags &= "-b" & b_Cvanal.Value & " "
        End If
        If d_Cvanal.Value > 0 Then
            tFlags &= "-d" & d_Cvanal.Value & " "
        End If

        tArguments &= tFlags & _
                      """" & InputFile_Cvanal.Text.Trim & """" & _
                      " " & _
                      """" & OutputFile_Cvanal.Text.Trim & """"

        StartCompiler(tArguments)
    End Sub

    Private Sub HETRO()
        Dim tArguments As String = " -U hetro "
        Dim tFlags As String = ""

        If s_Hetro.Value <> 10000 Then
            tFlags &= "-s" & s_Hetro.Value & " "
        End If
        If c_Hetro.Value <> 1 Then
            tFlags &= "-c" & c_Hetro.Value & " "
        End If
        If b_Hetro.Value > 0 Then
            tFlags &= "-b" & b_Hetro.Value & " "
        End If
        If d_Hetro.Value > 0 Then
            tFlags &= "-d" & d_Hetro.Value & " "
        End If

        If f_Hetro.Value <> 100 Then
            tFlags &= "-f" & f_Hetro.Value & " "
        End If
        If h_Hetro.Value <> 10 Then
            tFlags &= "-h" & h_Hetro.Value & " "
        End If
        If Max_Hetro.Value <> 32767 Then
            tFlags &= "-M" & Max_Hetro.Value & " "
        End If
        If min_Hetro.Value <> 64 Then
            tFlags &= "-m" & min_Hetro.Value & " "
        End If
        If n_Hetro.Value <> 256 Then
            tFlags &= "-n" & n_Hetro.Value & " "
        End If
        If l_Hetro.Value > 0 Then
            tFlags &= "-l" & l_Hetro.Value & " "
        End If

        tArguments &= tFlags & _
                      """" & InputFile_Hetro.Text.Trim & """" & _
                      " " & _
                      """" & OutputFile_Hetro.Text.Trim & """"

        StartCompiler(tArguments)
    End Sub

    Private Sub LPANAL()
        Dim tArguments As String = " -U lpanal "
        Dim tFlags As String = ""

        If s_Lpanal.Value <> 10000 Then
            tFlags &= "-s" & s_Lpanal.Value & " "
        End If
        If c_Lpanal.Value <> 1 Then
            tFlags &= "-c" & c_Lpanal.Value & " "
        End If
        If b_Lpanal.Value > 0 Then
            tFlags &= "-b" & b_Lpanal.Value & " "
        End If
        If d_Lpanal.Value > 0 Then
            tFlags &= "-d" & d_Lpanal.Value & " "
        End If

        If p_Lpanal.Value <> 34 Then
            tFlags &= "-p" & p_Lpanal.Value & " "
        End If
        If h_Lpanal.Value <> 200 Then
            tFlags &= "-h" & h_Lpanal.Value & " "
        End If
        If Max_Lpanal.Value <> 200 Then
            tFlags &= "-Q" & Max_Lpanal.Value & " "
        End If
        If Min_Lpanal.Value <> 70 Then
            tFlags &= "-P" & Min_Lpanal.Value & " "
        End If
        If a_Lpanal.Checked Then
            tFlags &= "-a "
        End If
        If Not v_Lpanal.Text.Contains("none") Then
            tFlags &= "-v" & v_Lpanal.SelectedIndex & " "
        End If
        If Comments_Lpanal.Text.Length > 0 Then
            tFlags &= "-C" & Comments_Lpanal.Text & " "
        End If

        tArguments &= tFlags & _
                      """" & InputFile_Lpanal.Text.Trim & """" & _
                      " " & _
                      """" & OutputFile_Lpanal.Text.Trim & """"

        StartCompiler(tArguments)
    End Sub

    Private Sub PVANAL()
        Dim tArguments As String = " -U pvanal "
        Dim tFlags As String = ""

        If s_Pvanal.Value <> 10000 Then
            tFlags &= "-s" & s_Pvanal.Value & " "
        End If
        If c_Pvanal.Value <> 1 Then
            tFlags &= "-c" & c_Pvanal.Value & " "
        End If
        If b_Pvanal.Value > 0 Then
            tFlags &= "-b" & b_Pvanal.Value & " "
        End If
        If d_Pvanal.Value > 0 Then
            tFlags &= "-d" & d_Pvanal.Value & " "
        End If

        tFlags &= "-n" & n_Pvanal.Text & " "

        If w_Pvanal.Text.Contains("Hop") Then
            tFlags &= "-h" & h_Pvanal.Text & " "
        ElseIf w_Pvanal.Text <> "4" Then
            tFlags &= "-w" & w_Pvanal.Text & " "
        End If

        If Not window_Pvanal.Text.Contains("Hann") Then
            If window_Pvanal.Text.Contains("Hamming") Then
                tFlags &= "-H "
            Else
                tFlags &= "-K "
            End If
        End If

        tArguments &= tFlags & _
                      """" & InputFile_Pvanal.Text.Trim & """" & _
                      " " & _
                      """" & OutputFile_Pvanal.Text.Trim & """"

        StartCompiler(tArguments)
    End Sub

    Private Sub SNDINFO()
        Dim tArguments As String = " -U sndinfo "
        tArguments &= """" & InputFile_Sndinfo.Text.Trim & """"
        StartCompiler(tArguments)
    End Sub

    Private Sub StartCompiler(ByVal arguments As String)

        'Replace "," with "." inside arguments string
        arguments = arguments.Replace(",", ".")

        'Call csound compiler [Utility -U]
        ''Example: " -U cvanal [FLAGS] inputfile outputfile"
        WxUtilityConsole1.Filename = Preferences.Directory.CSoundConsole
        WxUtilityConsole1.Arguments = arguments
        WxUtilityConsole1.StartCompiler(True)

    End Sub

    Private Sub WxUtilityConsole1_CompilerCompleted(ByVal mErrorLine As String, ByVal mWaveFile As String) Handles WxUtilityConsole1.CompilerCompleted
        'Add Extended compiler information to SCI_Output
        WxUtilityConsole1.SCI_Output.SetReadOnly(False)
        WxUtilityConsole1.SCI_Output.AppendText(vbCrLf & vbCrLf & "Extended Compiler Info:" & vbCrLf)
        WxUtilityConsole1.SCI_Output.AppendText(WxUtilityConsole1.SCI_Error.GetText)
        WxUtilityConsole1.SCI_Output.GotoPos(WxUtilityConsole1.SCI_Output.GetLength - 1)
        WxUtilityConsole1.SCI_Output.SetReadOnly(True)
    End Sub






    Private Sub ButtonInputCvanal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonInputCvanal.Click
        Dim ret As String = InputFileDialog()
        If ret = "" Then Exit Sub
        InputFile_Cvanal.Text = ret
        If InputFile_Cvanal.Text.Contains(".") Then
            OutputFile_Cvanal.Text = InputFile_Cvanal.Text.Substring(0, InputFile_Cvanal.Text.IndexOf("."))
        Else
            OutputFile_Cvanal.Text = InputFile_Cvanal.Text
        End If
        OutputFile_Cvanal.Text &= ".cva"
    End Sub

    Private Sub ButtonInputHetro_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonInputHetro.Click
        Dim ret As String = InputFileDialog()
        If ret = "" Then Exit Sub
        InputFile_Hetro.Text = ret
        If InputFile_Hetro.Text.Contains(".") Then
            OutputFile_Hetro.Text = InputFile_Hetro.Text.Substring(0, InputFile_Hetro.Text.IndexOf("."))
        Else
            OutputFile_Hetro.Text = InputFile_Hetro.Text
        End If
        OutputFile_Hetro.Text &= ".het"
    End Sub

    Private Sub ButtonInputLpanal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonInputLpanal.Click
        Dim ret As String = InputFileDialog()
        If ret = "" Then Exit Sub
        InputFile_Lpanal.Text = ret
        If InputFile_Lpanal.Text.Contains(".") Then
            OutputFile_Lpanal.Text = InputFile_Lpanal.Text.Substring(0, InputFile_Lpanal.Text.IndexOf("."))
        Else
            OutputFile_Lpanal.Text = InputFile_Lpanal.Text
        End If
        OutputFile_Lpanal.Text &= ".lpa"
    End Sub

    Private Sub ButtonInputPvanal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonInputPvanal.Click
        Dim ret As String = InputFileDialog()
        If ret = "" Then Exit Sub
        InputFile_Pvanal.Text = ret
        If InputFile_Pvanal.Text.Contains(".") Then
            OutputFile_Pvanal.Text = InputFile_Pvanal.Text.Substring(0, InputFile_Pvanal.Text.IndexOf("."))
        Else
            OutputFile_Pvanal.Text = InputFile_Pvanal.Text
        End If
        OutputFile_Pvanal.Text &= ".pva"
    End Sub

    Private Sub ButtonInputAtsa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonInputAtsa.Click
        Dim ret As String = InputFileDialog()
        If ret = "" Then Exit Sub
        InputFile_Atsa.Text = ret
        If InputFile_Atsa.Text.Contains(".") Then
            OutputFile_Atsa.Text = InputFile_Atsa.Text.Substring(0, InputFile_Atsa.Text.IndexOf("."))
        Else
            OutputFile_Atsa.Text = InputFile_Atsa.Text
        End If
        OutputFile_Atsa.Text &= ".ats"
    End Sub

    Private Sub ButtonInputSndinfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonInputSndinfo.Click
        Dim ret As String = InputFileDialog()
        If ret = "" Then Exit Sub
        InputFile_Sndinfo.Text = ret
    End Sub


    Private Sub ButtonOutputCvanal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOutputCvanal.Click
        OutputFile_Cvanal.Text = OutputFileDialog(OutputFile_Cvanal.Text, "Cvanal file (*.cva)|*.cva")
    End Sub

    Private Sub ButtonOutputHetro_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOutputHetro.Click
        OutputFile_Hetro.Text = OutputFileDialog(OutputFile_Hetro.Text, "Hetro file (*.het)|*.het")
    End Sub

    Private Sub ButtonOutputLpanal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOutputLpanal.Click
        OutputFile_Lpanal.Text = OutputFileDialog(OutputFile_Lpanal.Text, "Lpanal file (*.lpa)|*.lpa")
    End Sub

    Private Sub ButtonOutputPvanal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOutputPvanal.Click
        OutputFile_Pvanal.Text = OutputFileDialog(OutputFile_Pvanal.Text, "Lpanal file (*.pva)|*.pva")
    End Sub

    Private Sub ButtonOutputAtsa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOutputAtsa.Click
        OutputFile_Atsa.Text = OutputFileDialog(OutputFile_Atsa.Text, "Lpanal file (*.ats)|*.ats")
    End Sub

    Private Function InputFileDialog() As String

        Dim openFileDialog1 As New OpenFileDialog

        openFileDialog1.Filter = "All files (*.*)|*.*"
        openFileDialog1.FilterIndex = 1
        openFileDialog1.RestoreDirectory = True

        If Not (openFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK) Or _
                openFileDialog1.FileName = vbNullString Then
            Return ""
            Exit Function
        End If

        Return openFileDialog1.FileName
        openFileDialog1.Dispose()

    End Function

    Private Function OutputFileDialog(ByVal mFileName As String, ByVal mFilter As String) As String

        Dim saveFileDialog1 As New SaveFileDialog

        If mFileName.Contains(".") Then
            mFileName = mFileName.Substring(0, mFileName.IndexOf("."))
        End If

        saveFileDialog1.FileName = mFileName
        saveFileDialog1.Filter = mFilter & "|All files (*.*)|*.*"
        saveFileDialog1.FilterIndex = 1
        saveFileDialog1.RestoreDirectory = True

        If Not (saveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK) Or _
                saveFileDialog1.FileName = vbNullString Then
            Return ""
            Exit Function
        End If

        Return saveFileDialog1.FileName

    End Function






    Private Sub ButtonHelp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
                Handles ButtonHelpAtsa.Click, ButtonHelpCvanal.Click, _
                ButtonHelpHetro.Click, ButtonHelpLpanal.Click, _
                ButtonHelpPvanal.Click, ButtonHelpSndinfo.Click

        Dim UtilityName As String = TabControl1.SelectedTab.Text.Trim
        UtilityName = UtilityName.Substring(0, UtilityName.Length - 5).Trim

        TabControl1.SelectTab("TB_Help")
        TB_Help.Refresh()

        Dim mFile As String = Application.StartupPath & "\Help\" & UtilityName & ".html"
        If File.Exists(mFile) Then
            WebBrowserHelp.Navigate(mFile)
        Else
            If Not Preferences.Directory.CSoundHelpHTML = "" Then
                WebBrowserHelp.Navigate(Preferences.Directory.CSoundHelpHTML)
            End If
        End If

    End Sub

    Private Sub ToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles _
        ToolStripMenuItem0.Click, ToolStripMenuItem1.Click, ToolStripMenuItem2.Click, _
        ToolStripMenuItem3.Click, ToolStripMenuItem4.Click, ToolStripMenuItem5.Click, _
        ToolStripMenuItem6.Click

        Dim mControl As ToolStripMenuItem = DirectCast(sender, ToolStripMenuItem)
        TabControl1.SelectedIndex = CInt(mControl.Text)

    End Sub

    Private Sub FormAnalysis_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.Escape Then
            If WxUtilityConsole1.ProcessActive Then
                WxUtilityConsole1.StopCompiler()
            Else
                Me.Close()
            End If
        End If
    End Sub

    Private Sub WxUtilityConsole1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles WxUtilityConsole1.KeyDown
        If e.KeyCode = Keys.Escape Then
            FormAnalysis_KeyDown(Me, e)
        End If
    End Sub


    Private Sub WebBrowserHelp_PreviewKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles WebBrowserHelp.PreviewKeyDown
        If e.KeyCode = Keys.F5 Then
            ToolStripMenuItem_Click(New ToolStripMenuItem("4"), Nothing)
        End If

    End Sub


End Class